from django.contrib.auth.models import Permission,Group
from django.contrib.contenttypes.models import ContentType
from rest_framework import serializers

# 获取权限管理页面的权限数据
class PermissionSerializer(serializers.ModelSerializer):
    class Meta:
        model = Permission
        fields = "__all__"

# 获取权限新增页面的权限类型
class PermissionContentTypeSerializer(serializers.ModelSerializer):
    class Meta:
        model = ContentType
        fields = ("id","name")

# 可以获取用户组的数据
class GroupPermissionSerializer(serializers.ModelSerializer):
    class Meta:
        model = Group
        fields = "__all__"

# 可以获取增加用户组页面的权限表数据
class PermissionSimpleSerializer(serializers.ModelSerializer):
    class Meta:
        model = Permission
        fields = ("id","name")